package Java9_8;

import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Company {
    String name;
    String ip;
    String phone;
    String type;

    public Company(String name, String ip, String phone, String type) {
        this.name = name;
        this.ip = ip;
        this.phone = phone;
        this.type = type;
    }
    Person p=new Person();
    List list=new ArrayList();
    public boolean zhaopin(Person gh) {
        if (list.contains(gh)){
            return false;
        }
        return list.add(gh);
    }
    public void show(){
        for (int i=0;i<list.size();i++){
            System.out.println(list.get(i));
        }
    }
    public boolean citui(String gh){
        for (int i = 0; i <list.size() ; i++) {
            if (((Person) list.get(i)).getGonghao().equals(gh)){
              list.remove(i);
              return true;
            }
        }
        return false;
    }
    public int shuliang(){
    return list.size();
    }
    public Person maxmoney() {
            if (list.isEmpty()) {
                return null;
            }
        Person smax = (Person) list.get(0);
            for (int i = 1; i < list.size(); i++) {
                if (((Person) list.get(i)).getMoney() > smax.getMoney()) {
                    smax = (Person) list.get(i);
                }
            }
            return smax;
    }
}
